<?php
// Step 1 of web-cp setup
//   Server base configuration - e.g. Hostname, DNS Details, Password Key

if ($cfg['sysname'] == "" || $cfg['sysname']=='localhost') {
	$systemname = (($data['sysname'] != "") ? $data['sysname'] : $_SERVER['SERVER_NAME']);
} else {
	$systemname = $cfg['sysname'];
}

if ($cfg['sysipint'] == "") {
	$systemipint = (($data['sysipint'] != "") ? $data['sysipint'] : $cfg['sysipint']);
} else {
	$systemipint = $cfg['sysipint'];
}

if ($cfg['sysipext'] == "") {
	$systemipext = (($data['sysipext'] != "") ? $data['sysipext'] : $cfg['sysipext']);
} else {
	$systemipext = $cfg['sysipext'];
}

if ($cfg['dns_server1'] == "") {
	$dns_server1 = (($data['dns_server1'] != "") ? $data['dns_server1'] : (($systemname != "") ? "ns1.".$systemname : $cfg['dns_server1']));
} else {
	$dns_server1 = $cfg['dns_server1'];
}

if ($cfg['dns_server2'] == "") {
	$dns_server2 = (($data['dns_server2'] != "") ? $data['dns_server2'] : (($systemname != "") ? "ns2.".$systemname : $cfg['dns_server2']));
} else {
	$dns_server2 = $cfg['dns_server2'];
}

if ($cfg['adminmail'] == "") {
	preg_match("/[^\.\/]+\.[^\.\/]+$/",$systemname, $matches);
	$systemdomain = $matches[0];
	$adminemail = (($data['adminmail'] != "") ? $data['adminmail'] : "admin@".$systemdomain);
} else {
	$adminemail = $cfg['adminmail'];
}

if ($cfg['devhd'] == "") {
	$devhd = (($data['devhd'] != "") ? $data['devhd'] : $cfg['devhd']);
} else {
	$devhd = $cfg['devhd'];
}

// Find OS and make key for form
if ($data['submit'] == "") {
	$php_os = PHP_OS;
	if (strstr($php_os, "BSD")) {
		$guess_os = "freebsd/4";
	} elseif (strstr($php_os, "Linux")) {
		$guess_os = "linux/RHEL";
	} elseif (strstr($php_os, "Darwin")) {
		$guess_os = "mac/OSX";
	} elseif (strstr($php_os, "Win")) {
		$guess_os = "windows/32";
	}
	$os = (($data["os"] != "") ? $data["os"] : $guess_os);
} else {
	$os = $cfg['os']."/".$cfg['osversion'];
}
if ($cfg['key'] == "SECRET_KEY") {
	$key = (($data["key"] != "") ? $data["key"] : make_salt(20));
} else {
	$key = $cfg['key'];
}

?>
<!--BEGIN HTML-->
<!--<input type=hidden name="step" value="1">-->
<!-- SERVER CONFIGURATION -->
<div align="center">
<table border="0" cellpadding="0" cellspacing="0"><tr><td>
<table border="0" cellpadding="0" cellspacing="0" class="tblbg"><tr><td>
<table border="0" cellspacing="1">
	<tr>
		<td colspan="3" class="tbltop">&nbsp;Server Configuration&nbsp;</td>
	</tr>
	<tr>
		<td class="row1"><b>&nbsp;web-cp HTTP Server&nbsp;</b></td>
		<td class="row2">&nbsp;<select name="data[httpd_mode]">
									<option value="apache" <?=(($data['httpd_mode'] == 'apache')?' selected':'');?>> Dedicated Apache server</option>
									<option value="webcp" <?=(($data['httpd_mode'] == 'webcp')?' selected':'');?> <?=(($cfg['httpd_mode'] == 'webcp')?' selected':'');?>> Bundled php server</option>
								</select>&nbsp;</td>
		<td class="row2"><img src="/icon/question.png" width="24" height="24" onmouseover="popup(event,'HTTP Server')" onmouseout="popup(event,'HTTP Server')"></td>
	</tr>
	<tr>
		<td class="row1"><b>&nbsp;Server Domain&nbsp;</b></td>
		<td class="row2">&nbsp;<input type="text" name="data[sysname]" size="25" maxlength="255" value="<?=$systemname;?>">&nbsp;</td>
		<td class="row2"><img src="/icon/question.png" width="24" height="24" onmouseover="popup(event,'Server Domain')" onmouseout="popup(event,'Server Domain')"></td>
	</tr>
	<tr>
		<td class="row1"><b>&nbsp;Server IP - Internal&nbsp;</b></td>
		<td class="row2">&nbsp;<input type="text" name="data[sysipint]" size="25" maxlength="15" value="<?=$systemipint;?>">&nbsp;</td>
		<td class="row2"><img src="/icon/question.png" width="24" height="24" onmouseover="popup(event,'Server IP Int')" onmouseout="popup(event,'Server IP Int')"></td>
	</tr>
	<tr>
		<td class="row1"><b>&nbsp;Server IP - External&nbsp;</b></td>
		<td class="row2">&nbsp;<input type="text" name="data[sysipext]" size="25" maxlength="15" value="<?=$systemipext;?>">&nbsp;</td>
		<td class="row2"><img src="/icon/question.png" width="24" height="24" onmouseover="popup(event,'Server IP Ext')" onmouseout="popup(event,'Server IP Ext')"></td>
	</tr>
	<tr>
		<td class="row1"><b>&nbsp;Nameserver 1&nbsp;</b></td>
		<td class="row2">&nbsp;<input type="text" name="data[dns_server1]" size="25" maxlength="255" value="<?=$dns_server1;?>">&nbsp;</td>
		<td class="row2"><img src="/icon/question.png" width="24" height="24" onmouseover="popup(event,'Nameserver 1')" onmouseout="popup(event,'Nameserver 1')"></td>
	</tr>
	<tr>
		<td class="row1"><b>&nbsp;Nameserver 2&nbsp;</b></td>
		<td class="row2">&nbsp;<input type="text" name="data[dns_server2]" size="25" maxlength="255" value="<?=$dns_server2;?>">&nbsp;</td>
		<td class="row2"><img src="/icon/question.png" width="24" height="24" onmouseover="popup(event,'Nameserver 2')" onmouseout="popup(event,'Nameserver 2')"></td>
	</tr>
	<tr>
		<td class="row1"><b>&nbsp;Admin E-Mail&nbsp;</b></td>
		<td class="row2">&nbsp;<input type="text" name="data[adminmail]" size="25" maxlength="255" value="<?=$adminemail;?>">&nbsp;</td>
		<td class="row2"><img src="/icon/question.png" width="24" height="24" onmouseover="popup(event,'Admin E-Mail')" onmouseout="popup(event,'Admin E-Mail')"></td>
	</tr>
	<tr>
		<td class="row1"><b>&nbsp;Operating System&nbsp;</b></td>
		<td class="row2">&nbsp;<select name="data[os]">
			<option value="linux/RHEL" <?=(($os == "linux/RHEL") ? "selected" : "")?>>Linux - RHEL</option>
			<option value="linux/FedoraCore" <?=(($os == "linux/FedoraCore") ? "selected" : "")?>>Linux - Fedora Core</option>
			<option value="linux/RedHat" <?=(($os == "linux/RedHat") ? "selected" : "")?>>Linux - Red Hat (other)</option>
			<option value="linux/Debian" <?=(($os == "linux/Debian") ? "selected" : "")?>>Linux - Debian</option>
			<option value="linux/Suse" <?=(($os == "linux/Suse") ? "selected" : "")?>>Linux - Suse</option>
			<option value="linux/Slackware" <?=(($os == "linux/Slackware") ? "selected" : "")?>>Linux - Slackware</option>
			<option value="linux/Other" <?=(($os == "linux/Other") ? "selected" : "")?>>Linux - Other</option>
			<option value="freebsd/FreeBSD4" <?=(($os == "freebsd/FreeBSD4") ? "selected" : "")?>>FreeBSD - 4.0+</option>
			<option value="freebsd/OpenBSD" <?=(($os == "freebsd/OpenBSD") ? "selected" : "")?>>OpenBSD</option>
			<option value="freebsd/NetBSD" <?=(($os == "freebsd/NetBSD") ? "selected" : "")?>>NetBSD</option>
			<option value="solaris/10" <?=(($os == "solaris/10") ? "selected" : "")?>>Solaris - 10+</option>
			<option value="mac/OSX" <?=(($os == "mac/OSX") ? "selected" : "")?>>Mac OS X</option>
			<option value="windows/32" <?=(($os == "windows/32") ? "selected" : "")?>>Windows</option>
			<option value="linux/Unknown" <?=(($os == "linux/Unknown") ? "selected" : "")?>>Other</option>
		</select>&nbsp;</td>
		<td class="row2"><img src="/icon/question.png" width="24" height="24" onmouseover="popup(event,'Operating System')" onmouseout="popup(event,'Operating System')"></td>
	</tr>
	<tr>
		<td class="row1"><b>&nbsp;HDD Partition&nbsp;</b></td>
		<td class="row2">&nbsp;<input type="text" name="data[devhd]" size="25" maxlength="255" value="<?=$devhd;?>">&nbsp;</td>
		<td class="row2"><img src="/icon/question.png" width="24" height="24" onmouseover="popup(event,'HDD Partition')" onmouseout="popup(event,'HDD Partition')"></td>
	</tr>
	<tr>
		<td class="row1"><b>&nbsp;Default Language&nbsp;</b></td>
		<td class="row2">&nbsp;<select name="data[defaultlang]">
			<option value="danish">Danish</option>
			<option value="english" selected>English</option>
			<option value="french">French</option>
			<option value="german">German</option>
			<option value="norwegian">Norwegian</option>
			<option value="russian">Russian</option>
			<option value="spanish">Spanish</option>
			<option value="swedish">Swedish</option>
		</select>&nbsp;</td>
		<td class="row2"><img src="/icon/question.png" width="24" height="24" onmouseover="popup(event,'Default Language')" onmouseout="popup(event,'Default Language')"></td>
	</tr>
	<tr>
		<td class="row1"><b>&nbsp;Secret Key&nbsp;</b></td>
		<td class="row2">&nbsp;<input type="text" name="data[key]" size="25" maxlength="255" value="<?=$key;?>">&nbsp;</td>
		<td class="row2"><img src="/icon/question.png" width="24" height="24" onmouseover="popup(event,'Secret Key')" onmouseout="popup(event,'Secret Key')"></td>
	</tr>
</table>
</td></tr></table><br>
<!--END HTML-->
